<?php

class Tools extends TemplateEngine_base
{
	public function install_action()
	{
		$script = file_get_contents(FQ_ROOT."/install/systemtables.sql");
		$arr = explode('/', $script);

		$statement_arr = array();
		
		foreach($arr as $sql)
		{
			$stmt = array('text'=> str_replace("\n", "<br/>", $sql));
			try
			{
				DBUtils::instance()->execute($sql);
				$stmt['result']= 0;
			}
			catch(Exception $e)
			{
				$stmt['result']= -1;
				$stmt['message'] = $e->getMessage();
			}
						
			$statement_arr[] = $stmt;
		}
		
		$data = array(
			'statements' => $statement_arr
		);
		
		//print_r($statement_arr);
		return $this->generatePage($data);
		
	}
	
	
}
?>